<?php

class Corner_Model extends ORM {

	

	protected $table_name = 'corner';

	protected $primary_key = 'corner_id';

	protected $col_sort_order = 'corner_sort_order';

	protected $col_corner_status = 'corner_status';

		

	public function get()

	{

		$this->db->from($this->table_name);

		$this->db->select('*');

		$this->db->orderby($this->col_sort_order,'desc');

		$this->db->orderby($this->primary_key,'desc');

		$query = $this->db->get();

		return $query->result_array(false);

		

	}

	

	public function get_with_active($language)

	{

		$this->db->select('*');

		$this->db->from($this->table_name);

		$this->db->join('corner_content', 'corner_content.corner_id', 'corner.corner_id');

		$this->db->where('corner_content.languages_id',$language);

		$this->db->where($this->col_corner_status,'1');

		$this->db->orderby('corner.'.$this->col_sort_order,'desc');

		$this->db->orderby('corner.'.$this->primary_key,'desc');

		$query = $this->db->get();

		return $query->result_array(false);

		

	}
	public function count_row()
	{
		$this->db->select('COUNT('.$this->primary_key.') AS max');
		$this->db->from($this->table_name);
        $this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
	public function get_oder()
	{
		$this->db->from($this->table_name);
		$this->db->select($this->primary_key);
		$this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function get_with_list($language,$type)

	{

		$this->db->select('*');

		$this->db->from($this->table_name);

		$this->db->join('corner_content', 'corner_content.corner_id', 'corner.corner_id');
		
		//$this->db->join('corner_images', 'corner_images.corner_id', 'corner.corner_id');
		
		$this->db->where('corner_content.languages_id',$language);
		
		$this->db->where('corner.corner_type',$type);

		$this->db->where($this->col_corner_status,'1');

		$this->db->groupby('corner.corner_id');

		$this->db->orderby('corner.'.$this->primary_key,'desc');

		$query = $this->db->get();
//echo $this->db->last_query();
		return $query->result_array(false);

		

	}

}

?>